﻿Imports System.Windows.Forms
Friend NotInheritable Class ListViewSub
    Inherits ListViewVirtualMode


    Sub New(ByVal ListView As ListView, ByVal ListViewItem As List(Of ListViewItem))
        MyBase.new(ListView, ListViewItem)
    End Sub

    '===================================
    'ListView事件
    '===================================
    Private Sub ListView_RetrieveVirtualItem(ByVal sender As Object, ByVal e As System.Windows.Forms.RetrieveVirtualItemEventArgs) Handles ListView.RetrieveVirtualItem
        e.Item = ListViewItem(e.ItemIndex)

    End Sub
    Private Sub ListView_SearchForVirtualItem(ByVal sender As Object, ByVal e As System.Windows.Forms.SearchForVirtualItemEventArgs) Handles ListView.SearchForVirtualItem
        For i As Integer = 0 To ListViewItem.Count - 1
            If ListViewItem(i).Text = e.Text Then
                e.Index = ListViewItem(i).Index
                Exit For
            End If
        Next
    End Sub

    Protected Overrides Sub _Add(ByVal ListViewItem As ListViewItem)
        Me.ListViewItem.Add(ListViewItem)
    End Sub

    Protected Overrides Sub _UpDataGUI()
        ListView.VirtualMode = True
        ListView.VirtualListSize = ListViewItem.Count
        ListView.Invalidate()
    End Sub
End Class
